@layout("/common/_container.html"){
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>品牌管理管理</h5>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <div class="row">
							<div>
								<!-- <#NameCon id="condition" name="名称" />
								</div>
								 -->
								<div class="col-sm-8">
	                            @if(shiro.hasPermission("/itemBrand/add")){
	                                <#button class='btn btn-info' name="新增" icon="fa-plus" clickFun="ItemBrand.openAddItemBrand()"/>
	                            @}							
								</div>
								<div class="col-sm-4">						
			                        <div class="hidden-xs pull-right" id="ItemBrandTableToolbar" role="group">
		
			                            @if(shiro.hasPermission("/itemBrand/update")){
			                                <#button class='btn btn-info' name="导出Excel" icon="fa-file-excel-o" clickFun="ItemBrand.Export2Excel($('#ItemBrandGrid'))" space="true"/>
			                            @}
										<button type="button" aria-label="columns" class="btn btn-info" title="显示/显示过滤器" onclick="filterToolbar()">
											<i class="glyphicon glyphicon-search"></i> <span>记录过滤</span>
										</button>			                            
										<button type="button" aria-label="columns" class="btn btn-info btn-outline dropdown-toggle" data-toggle="dropdown" title="隐藏/显示列" onclick="columnSelector($('#ItemBrandGrid'))">
											<i class="glyphicon glyphicon-list"></i> <span class="caret"></span>
										</button>			                            
				                        <form action="${ctxPath}/itemBrand/Export2Excel" method="post" id="export2excel">
				                        	<input type="hidden" name="export2excel_params" id="export2excel_params">
				                        </form>
			                        </div>
		                        </div>
							</div>
                    	</div>
						<div class="row">
	                        <table id="ItemBrandGrid" />
	                        <div id="ItemBrandPager"></div>                        
						</div>
		            </div>
		        </div>
	        </div>
	    </div>
	</div>
<script>
	$.jgrid.defaults.width = 780;
	$.jgrid.defaults.responsive = true;
	$.jgrid.defaults.styleUI = 'Bootstrap';
	
    function datePick1(element) {
        $(element).datepicker({
				autoclose: true,
				format: 'yyyy/mm/dd',
				orientation : 'bottom'
		});
	}
    
    var select_isEnabled = ":;1:有效;0:无效";
    
	$(document).ready(function () {
		$("#ItemBrandGrid").jqGrid({
			url: '/itemBrand/list2',
			mtype: "GET",
			styleUI : 'Bootstrap',
			datatype: "json",
			colModel: [
	            @if(shiro.hasPermission("/itemBrand/update")||shiro.hasPermission("/itemBrand/delete")){
				{ label: '操作', name:'_act_', index:'', width:63, sortable:false, search: false, resizable: false, fixed:true},
				@}
				{ label: 'ID', name: 'brandId', index: 'brandId', hidden: true, search: true, resizable: true, fixed:true, sortable: true},			
				{ label: '品牌名称', name: 'brandName', index: 'brandName',width: 100, search:true, resizable:true, fixed:true, align: 'left', sortable: true, sorttype: "string",
					searchoptions : {sopt: ["cn","eq","nc"]}}, //, align: 'left', sorttype: 'text', formatter: 'text',
				{ label: '描述', name: 'brandShortDesc', index: 'brandShortDesc',width: 100, search:true, resizable:true, fixed:true},
				{ label: '商品分类', name: 'categoryIds', index: 'categoryIds', width: 100, search:true, resizable:true, fixed:true, align: 'right', sortable: true, sorttype: "numeric",
					searchoptions:{sopt: ["ge","gt","le","lt","ne"]}},
				{ label: '有效', name: 'isEnabled', index: 'isEnabled', width: 100, search:true, resizable:true, fixed:true, align: 'center', sortable: true, sorttype: "int",
					stype:'select', searchoptions:{sopt: ["eq"], value:select_isEnabled}, editable: false, formatter:'select', editoptions:{value:select_isEnabled}},
					
				//{ label: '有效', name: 'isEnabled', index: 'isEnabled', width: 100, search:true, resizable:true, fixed:true, align: 'center', sortable: true, sorttype: "int",
				//	stype:'select', searchoptions:{sopt: ["eq"], dataUrl:"/dict/selectOption/sys_state"}, editable: false, formatter:'select', editoptions:{dataUrl:"/dict/selectOption/sys_state"}},
				{ label: '创建日期', name: 'created', index: 'created', width: 100, search:true, resizable:true, fixed:true, align: 'center', sortable: true, sorttype: "date",
					searchoptions: {sopt: ["eq","ge","le","ne"], dataInit:datePick, attr:{title:'选择日期'}}},
			],
			cmTemplate: {autoResizable:false},
			footerrow: false,
			viewrecords: true,
			autowidth : true,
			height: 'auto',
			pager: "#ItemBrandPager",
			rowList: [10, 20, 50],
			rowNum: 10,
			rownumbers: true,
			loadonce: false,
			caption: "品牌管理",
			multiselect: false,
			storeNavOptions: false,
			navOptions: {	
				reloadGridOptions: { fromServer: true }, 
			},
			//filterToolbar: {defaultSearch:'cn',stringResult: true,searchOnEnter : true, searchOperators: true},
			gridComplete : function() {
				var ids = $("#ItemBrandGrid").jqGrid('getDataIDs');
				for (var i = 0; i < ids.length; i++) {
					var rowId = ids[i];
					var rowData = $('#ItemBrandGrid').jqGrid('getRowData',rowId);
					var info=''; be=''; ca='';
					//info = "<button class='btn btn-info btn-xs' title='查看'  onclick=\"ItemBrand.openItemBrandView('" + rowData.brandId + "');\"><i class='fa fa-info-circle'></i></button>&nbsp";
		            @if(shiro.hasPermission("/itemBrand/update")){
					be = "<button class='btn btn-primary btn-xs' title='编辑'  onclick=\"ItemBrand.openItemBrandDetail('" + rowData.brandId + "');\"><i class='fa fa-pencil'></i></button>&nbsp";
					@}
		            @if(shiro.hasPermission("/itemBrand/delete")){
					ca = "<button class='btn btn-danger btn-xs' title='删除'  onclick=\"ItemBrand.delete('" + rowData.brandId + "');\"><i class='fa fa-times'></i></button>";
					@}
					jQuery("#ItemBrandGrid").jqGrid('setRowData', ids[i], {
						_act_ :  info + be + ca 
					});
				};
				$("#gview_ItemBrandGrid > .ui-jqgrid-titlebar").hide(); 	//隐藏caption
				//$('#gsh_ItemBrandGrid__act_').html('<div class="btn btn-info btn-sm" icon="fa-search" onclick="$(\'#ItemBrandGrid\').jqGrid().searchGrid()">查询条件:</div>');
				filterToolbar();
				loadColState($("#ItemBrandGrid"));
			},
			ondblClickRow:function(row){
				var rowData = $('#ItemBrandGrid').jqGrid('getRowData',row);
				ItemBrand.openItemBrandView(rowData.brandId);
			},
	        resizeStop: function () {
				saveColState($("#ItemBrandGrid"));
	        },
			
	    })
	    .navGrid('#ItemBrandPager', {edit:false,
	    	add:false,
	    	del:false,
	    	search:true,
	    	refresh:true
	    })
		.searchGrid({multipleSearch:true, sopt: ['cn','eq','ne','le','ge'], showQuery: false}); //定义查询可用的操作符(全局)
		
		$("#searchmodfbox_ItemBrandGrid").find(".ui-jqdialog-titlebar-close").click();//初始化时关闭多条件查询
		//激活头部过滤条件                stringResult: true,
		$('#ItemBrandGrid').jqGrid('filterToolbar',{defaultSearch:'cn',stringResult: true,searchOnEnter : true, searchOperators: true});
		//filterToolbar();
		
		//$("tr.ui-search-toolbar").show();
		
		$(function(){
			$(window).resize(function(){   
				loadColState($("#ItemBrandGrid"));
			}); 
		});	
		
		function GetId() {
			var row = $("#ItemBrandGrid").jqGrid("getGridParam", "selrow");
			row = row ? $("#ItemBrandGrid").jqGrid("getRowData", row) : null;
			return row != null ? row.brandId : null;
		}
		
	});
	

</script>
<script src="${ctxPath}/static/modular/biz/itemBrand/itemBrand.js"></script>
@}
